package com.autumn.oauth2.client.config;

//@Configuration
//@EnableConfigurationProperties({ AuthorizationServerProperties.class })
public class Oauth2ClientConfig {

	/*@Autowired
	private AuthorizationServerProperties authorizationServerProperties;

	
	@Bean
	public OAuth2RestTemplate oauth2RestTemplate(OAuth2ClientContext context, OAuth2ProtectedResourceDetails details) {
		OAuth2RestTemplate template = new OAuth2RestTemplate(details, context);

		AuthorizationCodeAccessTokenProvider authCodeProvider = new AuthorizationCodeAccessTokenProvider();
		authCodeProvider.setStateMandatory(false);
		AccessTokenProviderChain provider = new AccessTokenProviderChain(Arrays.asList(authCodeProvider));
		template.setAccessTokenProvider(provider);
		return template;
	}
	

	*//**
	 * 注册处理redirect uri的filter
	 * 
	 * @param oauth2RestTemplate
	 * @param tokenService
	 * @return
	 *//*
	@Bean
	public OAuth2ClientAuthenticationProcessingFilter oauth2ClientAuthenticationProcessingFilter(
			OAuth2RestTemplate oauth2RestTemplate, RemoteTokenServices tokenService) {
		OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(
				"/userLogin");
		filter.setRestTemplate(oauth2RestTemplate);
		filter.setTokenServices(tokenService);

		// 设置回调成功的页面
		filter.setAuthenticationSuccessHandler(new SimpleUrlAuthenticationSuccessHandler() {
			public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
					Authentication authentication) throws IOException, ServletException {
				this.setDefaultTargetUrl("/userLogin");
				super.onAuthenticationSuccess(request, response, authentication);
			}
		});
		return filter;
	}	
	
	*//**
	 * 注册check token服务
	 * 
	 * @param details
	 * @return
	 *//*
	@Bean
	public RemoteTokenServices tokenService(OAuth2ProtectedResourceDetails details) {
		RemoteTokenServices tokenService = new RemoteTokenServices();
		tokenService.setCheckTokenEndpointUrl(authorizationServerProperties.getCheckTokenAccess());
		tokenService.setClientId(details.getClientId());
		tokenService.setClientSecret(details.getClientSecret());
		return tokenService;
	}*/
	
}
